package net.gamebug.guessthemovie;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.widget.Button;

public class Mainmenu extends Activity {

    MediaPlayer mpClick1;
    MediaPlayer mpClick2;
    Button btscores;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.mainmenu);
        mpClick1 = MediaPlayer.create(this, R.raw.click1);
        mpClick2 = MediaPlayer.create(this, R.raw.click2);
        
        Typeface font = Typeface.createFromAsset(getAssets(), "verdana.ttf");
        
        
        //Botao play
        Button next = (Button) findViewById(R.id.btnplay);
        next.setTypeface(font);
        next.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent myinIntent = new Intent(v.getContext(), Game.class);
                myinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivityForResult(myinIntent, 0);
                mpClick1.start();
            }
        });

        //Botao Score
        final Button btscores = (Button) findViewById(R.id.btnscores);
        btscores.setTypeface(font);
        btscores.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                /*
            	AnimationSet set = new AnimationSet(true);
            	Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF,30, Animation.RELATIVE_TO_SELF, 40);
            	animation.setDuration(1000);
            	set.addAnimation(animation);
            	btscores.startAnimation(set);
            	*/
            	Intent myinIntent = new Intent(v.getContext(), Scores.class);
            	myinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivityForResult(myinIntent, 0);
                mpClick2.start();
            	
            }
        });

        //Botao Options
        Button btoption = (Button) findViewById(R.id.btnoptions);
        btoption.setTypeface(font);
        btoption.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent myinIntent = new Intent(v.getContext(), Options.class);
                startActivityForResult(myinIntent, 0);
                mpClick1.start();
            }
        });

        //Botao Help
        Button bthelp = (Button) findViewById(R.id.btnhelp);
        bthelp.setTypeface(font);
        bthelp.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent myinIntent = new Intent(v.getContext(), Help.class);
                startActivityForResult(myinIntent, 0);
                mpClick2.start();
            }
        });
    }

    @Override
    public void onBackPressed() {
        AlertDialog.Builder alertbox = new AlertDialog.Builder(this); // prepare the alert box
        alertbox.setMessage("Are you sure you want to quit? "); // set the message to display
        alertbox.setPositiveButton("Yes", new DialogInterface.OnClickListener() { // set a positive/yes button and create a listener
            public void onClick(DialogInterface arg0, int arg1) {
                android.os.Process.killProcess(android.os.Process.myPid());
            }
        });

        alertbox.setNegativeButton("No", new DialogInterface.OnClickListener() { // set a negative/no button and create a listener
            public void onClick(DialogInterface arg0, int arg1) {}
        });

        alertbox.show(); // display box
    }
}